<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*
      constructor属性:
      每个原型对象里面都有constructor属性(constructor属性构造函数)
      constructor属性属性指向该原型对象的constructor属性
    */
    function Star(name, age) {
      this.name = name
      this.ag = age
    }
    /*
      Star.prototype.sing=function(){
        console.log("唱歌");
      }
      Star.prototype.dance=function(){
        console.log("跳舞");
      }
      const ldh = new Star("刘德华", 60)
      console.log(Star.prototype)
      console.log(Star.prototype.constructor === Star)true
    */
    Star.prototype = {
      constructor: Star, //让Star原型对象上的constructor重新指向Star
      sing() {
        console.log("唱歌")
      },
      dance() {
        console.log("跳舞")
      }
    }
    const ldh = new Star("刘德华", 60)
    //console.log(Star.prototype)已经没有constructor属性了
    //console.log(Star.prototype.constructor === Star)false

    console.log(Star.prototype)
    console.log(Star.prototype.constructor === Star)//true
  </script>
</body>

</html>